import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { SGuildPlayer } from "../../../../../Message/Game/SGuildPlayer";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { GTextFormat } from "../../../../common/GTextFormat";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GCheckBox } from "../../../../../com/mui/controls/GCheckBox";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { SPublicMiniPlayer } from "../../../../../Message/Public/SPublicMiniPlayer";
//class MemberRender
    
    export  class MemberRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            this.mouseEnabled = true;
            this.mouseChildren = false;
            this.buttonMode = true;
            addEventListener(flash.events.MouseEvent.ROLL_OVER, this.onMouseOver);
            addEventListener(flash.events.MouseEvent.ROLL_OUT, this.onMouseOut);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this.guildPlayer = arg1 as SGuildPlayer;
            this.miniPlayer = this.guildPlayer.miniPlayer;
            this.nameTxt.text = this.miniPlayer.name;
            this.positionTxt.text = GameDefConfig.instance.getPositionName(this.guildPlayer.position);
            return;
        }

        /* internal  */init(): void
        {
            var loc1=11661567;
            var loc2=new GTextFormat();
            graphics.beginFill(16777215, 0);
            graphics.drawRect(0, 0, 260, 25);
            graphics.endFill();
            this._checkBox = ObjCreate.createCheckBox("", 12, 0, 100, 28, this);
            this._checkBox.drawNow();
            this.addChild(this._checkBox);
            this.nameTxt = ObjCreate.createTextField("", 35, 5, 35, 20, this);
            this.nameTxt.selectable = false;
            this.nameTxt.mouseEnabled = false;
            this.nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this.positionTxt = ObjCreate.createTextField("", 180, 5, 35, 20, this);
            this.positionTxt.selectable = false;
            this.positionTxt.mouseEnabled = false;
            this.positionTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._overSkin = GlobalClass.getScaleBitmap(ImagesConst.Friend_over);
            this._overSkin.width = 220;
            this._overSkin.height = 25;
            this._overSkin.x = 30;
            ObjCreate.createBg(0, 25, 260, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */onMouseOver(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._overSkin.parent == null) 
            {
                addChildAt(this._overSkin, 0);
            }
            return;
        }

        /* internal  */onMouseOut(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!_selected) 
            {
                if (this._overSkin.parent) 
                {
                    removeChild(this._overSkin);
                }
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                if (this._overSkin.parent == null) 
                {
                    addChildAt(this._overSkin, 0);
                }
                this._checkBox.selected = true;
            }
            else 
            {
                if (this._overSkin.parent) 
                {
                    removeChild(this._overSkin);
                }
                this._checkBox.selected = false;
            }
            this._checkBox.drawNow();
            return;
        }

        /* internal */ /* var */nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */positionTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_checkBox: GCheckBox;

        /* internal */ /* var */_overSkin: ScaleBitmap;

        /* internal */ /* var */guildPlayer: SGuildPlayer;

        /* internal */ /* var */playerMiniInfo: PlayerMiniInfo;

        /* internal */ /* var */miniPlayer: SPublicMiniPlayer;
    }
